home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 002 / chedit.arc / EXAMP1.C < prev    next >
C/C++ Source or Header  |  1986-04-20  |  3KB  |  65 lines

  1. /*
  2.    Example program #1 from the CGRAPH documentation.
  3. */
  4. /*
  5.    Compile this with your compiler, then Link it with the supplied object
  6.    modules.
  7. */
  8. #include <stdio.h>
  9. #include <chedit.h>     /* Defines of the CHEDIT functions.  Use it if your
  10.                            compiler does strong type checking. */
  11. #include <cgraph.c>     /* The READCSET, WRITECSET, PRINTBANNER, and
  12.                            PRINTCOLUMN routines are C source, included in
  13.                            this file. */
  14. #define CYAN    1
  15. #define MAGENTA 2 
  16. #define WHITE   3       /* color definitions */
  17.  
  18. unsigned char shapes[1024];  /* the array to hold the character shapes */
  19. int message[20];             /* the array to hold the message to be plotted */
  20. int errno;                   /* to hold the return value from READCSET */
  21. int i,m;                     /* loop indices */
  22. unsigned long hold;          /* temporary storage for saving the system
  23.                                 graphics character vector */
  24. unsigned int ofs,seg;        /* the ofset and segment of the saved system
  25.                                 vector */
  26.  
  27. main()
  28.    {
  29.    errno = readcset(shapes,"alpha.chr");
  30.                                /* read the character set */
  31.    if (!errno)                 /* if all ok */
  32.       {
  33.       grmode(4);            /* set to 320 x 200 graphics */
  34.                             /* Use the routine appropriate to your compiler */
  35.       message[0] = 65;      /* graphics character 65 */
  36.       message[1] = 67;      /* etc. */
  37.       message[2] = 69;
  38.       hold = getvect();     /* save the system vector */
  39.       ofs = (unsigned int) (hold & 0xffff);
  40.       seg = (unsigned int) ((hold >> 16) & 0xffff);
  41.       setvect(shapes);      /* and insert our own */
  42.       printbanner(2,5,message,2,CYAN);
  43.                          /* print the message in color 1, cyan, at 2,5
  44.                             on the screen. Note that this displays only
  45.                             the first 2 characters, so the 3rd is "hidden" */
  46.       for (i = 0; i < 8*3*20; i++)
  47.                             /* rotate through all 8 columns of the 3 chars
  48.                                20 times */
  49.          {
  50.          for (m = 0; m < 1500; m++)  ;
  51.                            /* waste a little time */
  52.          bannerleft(shapes,message,3);
  53.                            /* rotate all left so all characters take turns
  54.                               being hidden */
  55.          printbanner(2,5,message,2,CYAN);
  56.                            /* and display it again */
  57.          }
  58.       for (m = 0; m < 30000; m++) ;
  59.                             /* one last time delay */
  60.       restorevect(ofs,seg); /* put the system vector back */
  61.       grmode(3);            /* turn the graphics off */
  62.                             /* use the routine appropriate to your compiler */
  63.       }                     /* end of the if */
  64.    }                        /* end of the program */
  65.